<template>
    <view class="content">
        <view class="box">
            <view class="item">
                <image src="../../static/icon/pw_01.png" class="pw-01"></image>
                <input type="password" v-model="password" placeholder="请输入原密码" class="inp">
            </view>
            <view class="item">
                <image src="../../static/icon/pw_02.png" class="pw-01"></image>
                <input type="password" v-model="newpass" placeholder="请输入新密码" class="inp">
            </view>
            <view class="item">
                <image src="../../static/icon/pw_03.png" class="pw-01"></image>
                <input type="password" v-model="compass" placeholder="请输入确认密码" class="inp">
            </view>
        </view>
        <view class="btn" @click="doSubmit">确认提交</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                password: '',
                newpass: '',
                compass: '',
            };
        },
        onLoad() {},
        methods: {
            doSubmit() {
                if (!this.password) {
                    this.$toast('请输入原密码')
                    return
                }
                if (!this.newpass) {
                    this.$toast('请输入新密码')
                    return
                }
                if (!this.compass) {
                    this.$toast('请输入确认密码')
                    return
                }
                if (this.newpass != this.compass) {
                    this.$toast('两次密码不一致！')
                    return
                }
                this.$ajax('update_password', {
                    user_token: this.$getSync('userToken'),
                    old_password:this.password,//原密码
                    new_password:this.newpass,//新密码
                }).then(ret => {
                    if (ret.success == 1000) {
                        this.$toast('提交成功');
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                    } else {
                        this.$toast(ret.msg);
                    }
                });
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
    .box{
        background-color: #fff;
        margin-top: 20rpx;
        padding: 0 25rpx;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .pw-01{
        width: 38rpx;
        height: 39rpx;
        margin-right: 20rpx;
    }
    .inp{
        flex: 1;
        height: 110rpx;
        border-bottom: 2rpx solid #e6e6e6;
    }
    .btn {
    	border-radius: 50rpx;
    	background: #00a1e9;
    	font-size: 34rpx;
    	color: #fff;
    	text-align: center;
        padding: 25rpx;
    	margin: 70rpx 25rpx;
    }
    
</style>
